﻿
using System.Collections.Generic;
using System.Linq;


namespace Weather3
{
    class CityViewModel
    {
        public List<CityCategory> Items { get; set; }

        public CityViewModel()
        {
            var citys = new List<City>
                             {
                                 new City {Title = "北京", Category = "北京", Subtitle = ""},// 
                                 new City {Title = "延庆", Category = "北京", Subtitle = ""},// 
                                 new City {Title = "大兴", Category = "北京", Subtitle = ""},// 
                                 new City {Title = "福州", Category = "福建", Subtitle = ""},// 
                                 new City {Title = "闽清", Category = "福建", Subtitle = ""},
                                 new City {Title = "罗源", Category = "福建", Subtitle = ""},
                                 new City {Title = "连江", Category = "福建", Subtitle = ""},
                                 new City {Title = "长乐", Category = "福建", Subtitle = ""},
                                 new City {Title = "福清", Category = "福建", Subtitle = ""},
                                 new City {Title = "平潭", Category = "福建", Subtitle = ""},
                                 new City {Title = "闽侯", Category = "福建", Subtitle = " "},//
                                 new City {Title = "厦门", Category = "福建", Subtitle = ""}, //

                                 new City {Title = "杭州", Category = "浙江", Subtitle = " "},//
                                 new City {Title = "泉州", Category = "福建", Subtitle = ""},// 
                               
                               
                                 new City {Title = "天津", Category = "天津", Subtitle = ""},
                                 new City {Title = "塘沽", Category = "天津", Subtitle = ""},
                                 new City {Title = "蓟县", Category = "天津", Subtitle = ""},
                                 new City {Title = "汉沽", Category = "天津", Subtitle = ""},
                                 new City {Title = "大港", Category = "天津", Subtitle = ""},
                                 new City {Title = "东丽", Category = "天津", Subtitle = ""},
                                 new City {Title = "津南", Category = "天津", Subtitle = ""},
                                 new City {Title = "北辰", Category = "天津", Subtitle = ""},
                                 new City {Title = "武清", Category = "天津", Subtitle = ""},
                                 new City {Title = "宝坻", Category = "天津", Subtitle = ""},
                                 new City {Title = "宁河", Category = "天津", Subtitle = ""},
                                 new City {Title = "静海", Category = "天津", Subtitle = ""},
                                 new City {Title = "西青", Category = "天津", Subtitle = ""},
                                 
                             };

            var citysByCategories = citys.GroupBy(x => x.Category)
                .Select(x => new CityCategory { Title = x.Key, Items = x.ToList() });

            Items = citysByCategories.ToList();
        }

    }
        public class City
        {
            public string Title { get; set; }
            public string Subtitle { get; set; }
            //public string Image { get; set; }
            public string Category { get; set; }
        }

        public class CityCategory
        {
            public string Title { get; set; }
            public List<City> Items { get; set; }
        }

   
}
